using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Headspring.Training.Domain.Model;
using Headspring.Training.WebUI.Presenters;
using Headspring.Training.WebUI.Views;
using StructureMap;

namespace Headspring.Training.WebUI
{
	public partial class Login : Page, ILoginView
	{
		private LoginPresenter _presenter;
		private Employee[] _employeesToList;

		public Employee[] EmployeesToList
		{
			get { return _employeesToList;  }
			set { _employeesToList = value; }
		}

		protected void Page_Load(object sender, EventArgs e)
		{
			_presenter = ObjectFactory.FillDependencies<LoginPresenter>();
			_presenter.Execute(this);

			foreach (Employee employee in _employeesToList)
			{
				ddlUsers.Items.Add(new ListItem(employee.GetFullName(), employee.UserName));
			}
		}

		protected void LogIn(object sender, EventArgs e)
		{
			_presenter.LogInSelectedUserName(ddlUsers.SelectedValue);
		}
	}
}